package com.silp.phoneinfo;



import android.app.ListActivity;
import android.content.Intent;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class PhoneInfoActivity extends ListActivity {
	private static final String MODEL_NUMBER = String.valueOf(android.os.Build.FINGERPRINT);
	private static final String KERNEL_VERSION = String.valueOf(System.getProperty("os.version"));
	private static final String KERNEL_NAME = String.valueOf(System.getProperty("os.name"));
	private static final String MANUFACTURER = String.valueOf(android.os.Build.MANUFACTURER);
	private static final String REVISION = String.valueOf(android.os.Build.VERSION.RELEASE);



	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Info myinfo = new Info(this);
		String BatteryCharge ="" + myinfo.Get_BatteryCharge();
		String Brightness	= "" + myinfo.GetBrightness();
		String CPUInfo		="" + myinfo.ReadCPUinfo();
		String Disk			="" + myinfo.ReadDisk();
		String MemoInfo		="" +myinfo.getMemoryInfo();
		String[] hwinfostr = new String[]{
				"Model number:	"+MODEL_NUMBER,
				"Kernel Version:	"+KERNEL_VERSION,
				"Kernel Name:	"+KERNEL_NAME,
				"Manufacturer:	"+MANUFACTURER,
				"Revision:	"+REVISION,
				"Battery Charge:	"+BatteryCharge + "%",
				"Brightness:	"+Brightness,
				"CPU Info: "+CPUInfo,
				"Memory Info: "+MemoInfo,
				""+Disk
		};

		setListAdapter(new ArrayAdapter<String>(this, R.layout.main, hwinfostr));

		ListView l = getListView();
		l.setTextFilterEnabled(true);
		int[] colors = {0, 0xFFFF0000, 0}; 
		l.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
		l.setDividerHeight(1);
		l.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

				Toast.makeText(getApplicationContext(), ((TextView) view).getText(),Toast.LENGTH_SHORT).show();
			}
		});
	}


	@Override

	public boolean onCreateOptionsMenu(Menu menu) {


		super.onCreateOptionsMenu(menu);


		int group1 = 1;

		MenuItem hardware = menu.add(group1,1,1,"Hardware Info");

		hardware.setIcon(R.drawable.hwicon);

		int group2 = 2;

		MenuItem network = menu.add(group2,2,2,"Network Info");

		network.setIcon(R.drawable.nwicon);
		int group3 = 3;

		MenuItem pkg = menu.add(group3,3,3,"Package Info");

		pkg.setIcon(R.drawable.packageicon);
		int group4 = 4;

		MenuItem Log = menu.add(group4,4,4,"ViewLog");

		Log.setIcon(R.drawable.viewlogicon);
		int group5 = 5;

		MenuItem Running = menu.add(group5,5,5,"Running Apps");

		Running.setIcon(R.drawable.runningicon);
		return true;

	}



	@Override 
	public boolean onOptionsItemSelected(MenuItem item) {
		switch(item.getItemId()) {
		case 1:
			Intent hardwareIntent = new Intent(this,PhoneInfoActivity.class);
			startActivity(hardwareIntent);
			break;
		case 2:
			Intent networkIntent = new Intent(this,Network.class);
			startActivity(networkIntent);
			break;
		case 3:
			Intent pkgIntent = new Intent(this,Pkg.class);
			startActivity(pkgIntent);
			break;
		case 4:
			Intent logIntent = new Intent(this,Mylog.class);
			startActivity(logIntent);
			break;
		case 5:
			Intent runningIntent = new Intent(this,Running.class);
			startActivity(runningIntent);
			break;
		} 
		return true;
	}


}
